<?php
	

		class networkAction extends userAction{	
			
			protected function _initialize() {
				parent::_initialize();
			}
			
			public function index(){
				$network = $this->userInfo['network_city'];
				$userList = D("user")->findAll("network_city='$network'","id,username","RAND()",6); //随机得到5个用户
				$dao = new userModel();
				$dbpr = C("DB_PREFIX");
				$blogList = $dao->query("SELECT a.id, a.username, b.id, b.title, b.regtime FROM ".$dbpr."blogs b LEFT JOIN ".$dbpr."user a ON ( a.id = b.userid ) WHERE a.network_city = '$network'");
				
				$albumList = $dao->query("SELECT a.username, b.id, b.name, b.userid, b.regtime , b.defaultphoto FROM ".$dbpr."albums b LEFT JOIN ".$dbpr."user a ON ( a.id = b.userid ) WHERE a.network_city = '$network' ORDER BY RAND() LIMIT 5");

				$shareList = $dao->query("SELECT a.username, b.* FROM ".$dbpr."shars b LEFT JOIN ".$dbpr."user a ON ( a.id = b.userid ) WHERE a.network_city = '$network' LIMIT 10");
				
				$groupList = $dao->query("SELECT id,name,img,usernum,topicnum FROM ".$dbpr."groups ORDER BY RAND() LIMIT 5");//随机五个群组

				$this->assign("userList",$userList);
				//$this->assign("blogList",$blogList);
				$this->assign("albumList",$albumList);
				$this->assign("shareList",$shareList);
				$this->assign("groupList",$groupList);
				$this->display();
				
			}


			public function rand(){
				$network = $this->userInfo->network_city;
				$userList = D("user")->findAll("network_city='$network'","id,username","RAND()",6); //随机得到5个用户
				$this->assign("userList",$userList);
				isset($_GET["ajax"]) ? $this->display("rand4ajax") :  $this->display();
			}
		}
?>